﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Xml.Linq;
using HomeBuyerTools.FinanceProperties;
using HomeBuyerTools.ViewModels;
using System.Windows.Controls.Primitives;

namespace HomeBuyerTools.Views
{
    public partial class Page1 : PhoneApplicationPage
    {
        public Page1()
        {
            InitializeComponent();
            Loaded += Page1_Loaded;
        }

        void Page1_Loaded(object sender, RoutedEventArgs e)
        {
            LayoutRoot.Background = Custom.getPivotBackground();
             XElement xmlDoc =
               XElement.Load(@"XmlData\HelpMenu.xml");
             List<HelpMenu> ListHelpMenuPro = new List<HelpMenu>();
             foreach (XElement item in xmlDoc.Elements())
             {
                 HelpMenu HelpPro = new HelpMenu();
                 HelpPro.id = Convert.ToInt32(item.Attribute("id").Value);
                 HelpPro.name = item.Element("name").Value;
                 HelpPro.Url = item.Element("url").Value;
                 ListHelpMenuPro.Add(HelpPro);
             }
             ListHelpMenu.ItemsSource = ListHelpMenuPro;
        }

        private void imgTitle_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {

        }

        private void ListHelpMenu_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            try
            {
            NavigationService.Navigate(new Uri("/Views/Help.xaml", UriKind.Relative));

            var selecteditem = (sender as Selector).SelectedItem as HelpMenu;
            App.Helpid = selecteditem.id;
            App.Helpurl = selecteditem.Url;

            }
            catch(Exception ex)
            {
            }
        }
    }
}